package com.panopset.gui.container;

import java.awt.FlowLayout;
import java.awt.LayoutManager;

import javax.swing.JTextArea;

import com.panopset.swing.App;
import com.panopset.swing.FontManager;

/**
 * JTextArea persistent container.
 *
 * @author Karl Dinwiddie
 *
 */
public final class PanTextArea extends PanField<JTextArea> {


    /**
     * @param prompt
     *            Prompt.
     * @param toolTipText
     *            Tool tip text.
     * @param defaultValue
     *            Default value.
     */
    public PanTextArea(final String prompt, final String toolTipText,
            final String defaultValue) {
        super(prompt, toolTipText, defaultValue);
    }

    @Override
    public JTextArea createComponent() {
        JTextArea rtn = new JTextArea();
        App.app.fontManager.registerComponent(rtn, FontManager.FontType.monospace);
        return rtn;
    }

    @Override
    public String getComponentValue() {
        return getInnerComponent().getText();
    }

    @Override
    public void setComponentValue(final String value) {
        getInnerComponent().setText(value);
    }

    @Override
    protected LayoutManager createLayout() {
        return new FlowLayout();
    }

    @Override
    protected boolean isValid(final String valueToCheck) {
        return true;
    }

}
